import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart';

import 'package:flutter/services.dart';
class PermissionUtil{




//  static Future<bool> requestPermissions() async {
////  申请权限
//    Map<PermissionGroup, PermissionStatus> permissions =
//    await PermissionHandler().requestPermissions([
//      PermissionGroup.storage,
//      PermissionGroup.camera,
//    ]);
////  申请结果
//    PermissionStatus permissionStatus =
//    await PermissionHandler().checkPermissionStatus(PermissionGroup.camera);
//    if (permissionStatus == PermissionStatus.granted) {
//      print('申请成功');
//    } else {
//      print('申请被拒绝');
//      bool isShow = await PermissionHandler()
//          .shouldShowRequestPermissionRationale(PermissionGroup.camera);
//      if (!isShow) {
//        print('当前权限已被禁用申请，请在设置中手动开启后退出重新进入程序');
//        await PermissionHandler().openAppSettings();
//      } else {
//        PermissionStatus ps = await PermissionHandler()
//            .checkPermissionStatus(PermissionGroup.camera);
//        if (ps == PermissionStatus.granted) {
//          print('登录成功！');
//        } else {
//           requestPermissions();
//        }
//      }
//    }
//  }


  static Future<PermissionStatus> requestPermission(Permission permission) async {
    final status = await permission.request();

    return status;
  }

}